package com.blogspot.radialmind;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class NormalGraph extends AbstractGraph {
	
	private List<List<ITerm>> data = new ArrayList<List<ITerm>>();
	private List<ITerm> averages = new ArrayList<ITerm>();
	
	public NormalGraph( String title, List<ITerm> columns ) {
		super( title, columns );
	}
	
	public void addData( List<ITerm> terms ) {
		data.add( terms );
	}
	
	public void addAverage( List<ITerm> terms ) {
		averages.addAll( terms );
	}
	
	public long getStartTimestamp() {
		if ( data.size() > 0 ) {
			List<ITerm> list = data.get(0);
			DateTerm dt = (DateTerm)list.get( 1 );
			return dt.getDate().getTime() / 1000L;
		}
		return 0L;
	}
	public long getEndTimestamp() {
		if ( data.size() > 0 ) {
			List<ITerm> list = data.get( data.size() - 1 );
			DateTerm dt = (DateTerm)list.get( 1 );
			return dt.getDate().getTime() / 1000L;
		}
		return 0L;		
	}
	
	public String getName() {
		return getTitle();
	}
	public Set<String> getKeys() {
		Set<String> set = new HashSet<String>();
		set.add( "" );
		return set;
	}
	public ITerm getData( String key, int row, int col ) {
		return data.get( row ).get( col );	
	}
	public int getNumDataRows() {
		return data.size();
	}
}
